﻿package ygg.encoding.swf.abc
{
	import ygg.encoding.swf.abc.constant.Kind;
	
	public class ConstantPool
	{
		public var ints:Array;
		public var uints:Array;
		public var doubles:Array;
		public var strings:Array;
		public var namespaces:Array;
		public var nsSets:Array;
		public var multinames:Array;
		
		
		public function ConstantPool()
		{
			
		}
		
		public function getPool(u:uint):Object
		{
			var retVal:Object;
			
			switch (u)
			{
				case Kind.UTF8:
					retVal = strings;
					break;
				case Kind.INT:
					retVal = ints;
					break;
				case Kind.UINT:
					retVal = uints;
					break;
				case Kind.DOUBLE:
					retVal = doubles;
					break;
				case Kind.FALSE:
					retVal = { 10:false };
					break;
				case Kind.TRUE:
					retVal = { 11:true };
					break;
				case Kind.NAMESPACE:
				case Kind.PRIVATE_NS:
				case Kind.PACKAGE_NAMESPACE:
				case Kind.PACKAGE_INTERNAL_NS:
				case Kind.PROTECTED_NAMESPACE:
				case Kind.EXPLICIT_NAMESPACE:
				case Kind.STATIC_PROTECTED_NS:
					retVal = namespaces;
				case Kind.NULL:
					retVal = { 12: null };
					break;
				case Kind.UNDEFINED:
					retVal = { 0: undefined };
					break;
				default:
					throw new Error('INVALID CONSTANT');
			}
			
			return retVal;
		}
	}
	
}